<!DOCTYPE html>
<html>
  <head>
    <title>jslint4java maven plugin</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link href="jslint4java.css" type="text/css" rel="stylesheet" />
    <link href="prettify.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" src="prettify.js"></script>
  </head>
  <body>
    <h1>jslint4java maven plugin</h1>

    <p>
      If you are using maven to build an application which contains
      JavaScript, you can arrange for JSLint to run automatically.
    </p>

    <p>Here's an example configuration.</p>

    <pre class="prettyprint">
&lt;project&gt;
  …
  &lt;build&gt;
    …
    &lt;plugins&gt;
      …
      &lt;plugin&gt;
        &lt;groupId&gt;com.googlecode.jslint4java&lt;/groupId&gt;
        &lt;artifactId&gt;jslint4java-maven-plugin&lt;/artifactId&gt;
        &lt;version&gt;${project.version}&lt;/version&gt;
        &lt;executions&gt;
          &lt;execution&gt;
            &lt;id&gt;lint&lt;/id&gt;
            &lt;phase&gt;process-resources&lt;/phase&gt;
            &lt;goals&gt;
              &lt;goal&gt;lint&lt;/goal&gt;
            &lt;/goals&gt;
            &lt;configuration&gt;
              &lt;failOnError&gt;true&lt;/failOnError&gt;
              &lt;options&gt;
                &lt;undef&gt;true&lt;/undef&gt;
              &lt;/options&gt;
            &lt;/configuration&gt;
          &lt;/execution&gt;
        &lt;/executions&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;
&lt;/project&gt;
    </pre>

    <p>
      This will arrange for the jslint4java-maven-plugin to execute before
      the rest of your build.  If you would prefer to execute it afterwards,
      choose <code>&lt;phase&gt;verify&lt;/phase&gt;</code> instead.
    </p>

    <p>
      If you would prefer to run the linter on an ad-hoc basis, you can
      call the plugin from the command line.
    </p>

    <pre class="prettyprint">
$ mvn jslint4java:lint
    </pre>

    <p>
      In order to support this, you should still configure the plugin as part
      of your project, but not bind it to the lifecycle.  e.g.
    </p>

    <pre class="prettyprint">
&lt;project&gt;
  &hellip;
  &lt;build&gt;
    &hellip;
    &lt;plugins&gt;
      &hellip;
      &lt;plugin&gt;
        &lt;groupId&gt;com.googlecode.jslint4java&lt;/groupId&gt;
        &lt;artifactId&gt;jslint4java-maven-plugin&lt;/artifactId&gt;
        &lt;version&gt;${project.version}&lt;/version&gt;
        &lt;configuration&gt;
          &lt;failOnError&gt;true&lt;/failOnError&gt;
          &lt;options&gt;
            &lt;undef&gt;true&lt;/undef&gt;
          &lt;/options&gt;
        &lt;/configuration&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;
&lt;/project&gt;
    </pre>

    <h3 id="configuration">Configuration</h3>

    <p>
      The plugin is mainly controlled via the
      <code>&lt;configuration&gt;</code> element.
      It supports these children.
    </p>

    <table>
      <tr>
        <th>Element</th>
        <th>Description</th>
        <th>Default</th>
      </tr>

      <tr>
        <td><code>&lt;encoding&gt;</code></td>
        <td>What encoding to read the source files in.</td>
        <td>
          <pre class="prettyprint">
&lt;encoding&gt;UTF-8&lt;/encoding&gt;
          </pre>
        </td>
      </tr>

      <tr>
        <td><code>&lt;excludes&gt;</code></td>
        <td>A comma separated list of patterns to exclude from linting.</td>
        <td>
          <pre class="prettyprint">
&lt;excludes&gt;
  &lt;!-- no excludes by default --&gt;
&lt;/excludes&gt;
          </pre>
        </td>
      </tr>

      <tr>
        <td><code>&lt;includes&gt;</code></td>
        <td>A comma separated list of filename patterns lint.</td>
        <td>
          <pre class="prettyprint">
&lt;includes&gt;
  &lt;include&gt;**/*.js&lt;/include&gt;
&lt;/includes&gt;
          </pre>
        </td>
      </tr>

      <tr>
        <td><code>&lt;jslintSource&gt;</code></td>
        <td>An alternative <code>jslint.js</code> to use, in case the builtin version is insufficient.</td>
        <td>
          <pre class="prettyprint">
&lt;!-- The builtin version. --&gt;
&lt;jslintSource&gt;&lt;/jslintSource&gt;
          </pre>
        </td>
      </tr>

      <tr>
        <td><code>&lt;options&gt;</code></td>
        <td>
          Which options to pass to JSLint.  Each option must be specified as
          child element, e.g.
          <pre class="prettyprint">
&lt;maxlen&gt;72&lt;/maxlen&gt;
&lt;predef&gt;console, jQuery&lt;/predef&gt;
&lt;undef&gt;true&lt;/undef&gt;
          </pre>
          Please see
          <a href="apidocs/com/googlecode/jslint4java/Option.html">Option</a>
          for the full list of Options that can be specified.
        </td>
        <td>
          <pre class="prettyprint">
&lt;options&gt;
  &lt;!-- no options enabled by default --&gt;
&lt;/options&gt;
          </pre>
        </td>
      </tr>

      <tr>
        <td><code>&lt;outputFolder&gt;</code></td>
        <td>Where to write the report files.  JSLint generates the same report in several
        different formats.
        <dl>
        <dt><code>jslint.xml</code><dd>jslint4java's own XML format.
        <dt><code>junit.xml</code><dd>JUnit style reports.
        <dt><code>checkstyle.xml</code><dd>Checkstyle reports format.
        <dt><code>report.html</code><dd>JSLint's own HTML report.
        <dt><code>report.txt</code><dd>A plain text report.
        </dl>
        </td>
        <td>
          <pre class="prettyprint">
&lt;outputFolder&gt;\${project.build.directory}/jslint4java&lt;/outputFolder&gt;
          </pre>
        </td>
      </tr>

      <tr>
        <td><code>&lt;sourceFolders&gt;</code></td>
        <td>One or more folders to find the JavaScript files to lint.</td>
        <td>
          <pre class="prettyprint">
&lt;sourceFolders&gt;
  &lt;sourceFolder&gt;\${basedir}/src/main/webapp&lt;/sourceFolder&gt;
&lt;/sourceFolders&gt;
          </pre>
        </td>
      </tr>

      <tr>
        <td><code>&lt;timeout&gt;</code></td>
        <td>How many seconds JSLint is allowed to run for.</td>
        <td>
          <pre class="prettyprint">
&lt;!-- infinite --&gt;
&lt;timeout&gt;0&lt;/timeout&gt;
          </pre>
        </td>
      </tr>

    </table>

    <script type="text/javascript">prettyPrint()</script>
  </body>
</html>
